package com.literature.search.core.config.swagger;

import com.literature.search.core.enums.CodeEnum;
import org.springframework.context.annotation.Bean;
import org.springframework.web.bind.annotation.RequestMethod;
import springfox.documentation.builders.ParameterBuilder;
import springfox.documentation.builders.ResponseMessageBuilder;
import springfox.documentation.schema.ModelRef;
import springfox.documentation.service.Parameter;
import springfox.documentation.service.ResponseMessage;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * @Author: DangKong
 * @Date: 2023/3/1 15:54
 * @Description: 每个模块swagger配置的基类
 */

public class BaseSwaggerConfiguration {
    private static List<Parameter> globalOperationParameters = null;

    //初始化全局参数
    public static void initGlobalOperationParameters() {
        //添加head参数配置
        ParameterBuilder tokenPar = new ParameterBuilder();
        globalOperationParameters = new ArrayList<>();
        tokenPar.name("token").description("令牌").modelRef(new ModelRef("string")).parameterType("header").required(false).build();
        globalOperationParameters.add(tokenPar.build());
    }

    public static List<Parameter> getGlobalOperationParameters() {
        if (globalOperationParameters == null) {
            initGlobalOperationParameters();
        }
        return globalOperationParameters;
    }

}
